home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / crc.lqr / CRCCALC.ASM < prev   
Assembly Source File  |  1985-06-03  |  3KB  |  77 lines

  1.     PAGE    64,132
  2. ;******************************************************************************
  3. ;
  4. ;                CRCCALC - Calculate CRC for block of data
  5. ;
  6. ;******************************************************************************
  7. ;
  8. ;
  9. ;    Modified 31 May, 1984 for L-model of Lattice C V2.00
  10. ;
  11. ;                        John F. Ratti
  12. ;                        12  May, 1984
  13. ;
  14. ;******************************************************************************
  15. ;
  16. ;                        c/o Computer Power, Inc.
  17. ;                        P. O. Box 2388
  18. ;                        Jacksonville, FL  32231
  19. ;                        (904) 350-1400
  20. ;
  21. ;******************************************************************************
  22. _PROG    SEGMENT    BYTE
  23.     PUBLIC    CRCCALC
  24.     ASSUME    CS:_PROG
  25. CRCCALC    PROC    FAR
  26.     PUSH    BP            ;save BP
  27.     PUSH    DS            ;save DS            12MAY84
  28.     MOV    BP,SP            ;get stack pointer
  29.     MOV    BX,[BP+8]        ;get previous CRC
  30.     MOV    CX,[BP+14]        ;get length of data
  31.     MOV    DX,1021H        ;load constant for CCITT CRC (replace
  32.                     ;"1021H" with "8005H" for IBM SYNC CRC)
  33.     LDS    SI,DWORD PTR [BP+10]    ;get long pointer to data    12MAY84
  34.     CLD                ;we will work from low to high address
  35. A0:    LODSB                ;get a data byte
  36. B0:    SHL    AL,1            ;move high-order bit into carry
  37.     RCL    BX,1            ;shift carry bit into CRC
  38.     JNB    B1            ;if carry is 0, bypass XOR
  39.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  40. B1:    SHL    AL,1            ;move high-order bit into carry
  41.     RCL    BX,1            ;shift carry bit into CRC
  42.     JNB    B2            ;if carry is 0, bypass XOR
  43.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  44. B2:    SHL    AL,1            ;move high-order bit into carry
  45.     RCL    BX,1            ;shift carry bit into CRC
  46.     JNB    B3            ;if carry is 0, bypass XOR
  47.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  48. B3:    SHL    AL,1            ;move high-order bit into carry
  49.     RCL    BX,1            ;shift carry bit into CRC
  50.     JNB    B4            ;if carry is 0, bypass XOR
  51.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  52. B4:    SHL    AL,1            ;move high-order bit into carry
  53.     RCL    BX,1            ;shift carry bit into CRC
  54.     JNB    B5            ;if carry is 0, bypass XOR
  55.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  56. B5:    SHL    AL,1            ;move high-order bit into carry
  57.     RCL    BX,1            ;shift carry bit into CRC
  58.     JNB    B6            ;if carry is 0, bypass XOR
  59.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  60. B6:    SHL    AL,1            ;move high-order bit into carry
  61.     RCL    BX,1            ;shift carry bit into CRC
  62.     JNB    B7            ;if carry is 0, bypass XOR
  63.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  64. B7:    SHL    AL,1            ;move high-order bit into carry
  65.     RCL    BX,1            ;shift carry bit into CRC
  66.     JNB    B8            ;if carry is 0, bypass XOR
  67.     XOR    BX,DX            ;XOR w/CCITT CRC constant
  68. B8:    LOOP    A0            ;loop until all data processed
  69.     MOV    AX,BX            ;put CRC into return register
  70. EXIT:    POP    DS            ;get DS back            12MAY84
  71.     POP    BP            ;get BP back
  72.     RET                ;return to caller
  73. CRCCALC    ENDP
  74. _PROG    ENDS
  75.     END
  76. ;****************************** end of CRCCALC.ASM ****************************
  77.